package com.example.bookexchange;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private EditText editTextPhone, editTextPassword;
    private Button buttonLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 初始化控件
        editTextPhone = findViewById(R.id.editTextPhone);
        editTextPassword = findViewById(R.id.editTextPassword);
        buttonLogin = findViewById(R.id.buttonLogin);

        // 设置登录按钮的点击监听器
        buttonLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 获取输入的手机号和密码
                String phone = editTextPhone.getText().toString();
                String password = editTextPassword.getText().toString();

                // 检查输入是否为空
                if (!phone.isEmpty() && !password.isEmpty()) {
                    // 启动 HomeActivity
                    Intent intent = new Intent(MainActivity.this, HomeActivity.class);
                    startActivity(intent);
                } else {
                    // 提示用户输入不能为空
                    Toast.makeText(MainActivity.this, "请输入手机号和密码", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

}
